var t = getApp();

Page({
    data: {
        mark_id: "",
        getSucceed: !1
    },
    onLoad: function(e) {
        if (e.k && (this.data.mark_id = e.k), e.scene) {
            var a = decodeURIComponent(e.scene);
            if (a) {
                var n = [];
                n = a.split(",");
                for (var o = 0; o < n.length; o++) {
                    var i;
                    "mark_id" == (i = n[o].split("="))[0] && this.setData({
                        mark_id: i[1]
                    }), "mid" == i[0] && t._setMid(i[1]);
                }
            }
        }
        this.getData(), wx.setNavigationBarTitle({
            title: "优惠券分享"
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {
        var t = wx.getStorageSync("yz_uid"), e = wx.getStorageSync("nickname") ? wx.getStorageSync("nickname") : "", a = "";
        return t && (a = t), {
            title: "".concat(e, "向您分享").concat(this.data.item ? this.data.item.name : "优惠券"),
            path: "/packageI/shareGet/shareGet?k=".concat(this.data.mark_id, "&mid=").concat(a)
        };
    },
    onShareTimeline: function() {
        var t = wx.getStorageSync("yz_uid"), e = wx.getStorageSync("nickname") ? wx.getStorageSync("nickname") : "", a = "";
        return t && (a = t), {
            title: "".concat(e, "向您分享").concat(this.data.item ? this.data.item.name : "优惠券"),
            path: "/packageI/shareGet/shareGet?k=".concat(this.data.mark_id, "&mid=").concat(a)
        };
    },
    goMyCoupon: function() {
        wx.redirectTo({
            url: "/packageA/member/coupon_v2/coupon_v2"
        });
    },
    goConponCenter: function() {
        wx.redirectTo({
            url: "/packageD/coupon/coupon_store"
        });
    },
    tapGet: function() {
        var e = this, a = {
            mark_id: this.data.mark_id
        }, n = t.getNetAddresss("plugin.share-coupons.Frontend.controllers.share.handle");
        t._getNetWork({
            url: n,
            data: a,
            success: function(a) {
                var n = a.data;
                1 == n.result ? e.setData({
                    getSucceed: !0
                }) : t.tips(n.msg);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getData: function() {
        var e = this, a = {
            mark_id: this.data.mark_id
        }, n = t.getNetAddresss("plugin.share-coupons.Frontend.controllers.share.index");
        t._getNetWork({
            url: n,
            data: a,
            success: function(a) {
                var n = a.data;
                1 == n.result ? (e.setData({
                    item: n.data
                }), e.data.item.name.length >= 12 ? e.data.fontsize = "26rpx" : e.data.fontsize = "45rpx") : 1 == n.data.used ? wx.showToast({
                    title: "优惠券已被领取完",
                    icon: "none",
                    duration: 1e3,
                    success: function(t) {
                        setTimeout(function() {
                            wx.redirectTo({
                                url: "/packageA/member/coupon_v2/coupon_v2"
                            });
                        }, 1e3);
                    }
                }) : t.tips(n.msg);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
});